/*
 * @Description:
 * @Version: 1.668
 * @Autor: 地虎降天龙
 * @Date: 2024-05-30 19:13:33
 * @LastEditors: 地虎降天龙
 * @LastEditTime: 2025-09-04 14:43:25
 */
import { echartOptionProfixHandle, PublicConfigClass } from 'PLS/goView/lib/packages/public'
import { PieCommonConfig } from './index'
import { CreateComponentType } from 'PLS/goView/lib/packages/index.d'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'

export const includes = ['legend']

export enum PieTypeEnum {
    NORMAL = '常规图',
    RING = '环形图',
    ROSE = '玫瑰图',
}

export const PieTypeObject = {
    [PieTypeEnum.NORMAL]: 'nomal',
    [PieTypeEnum.RING]: 'ring',
    [PieTypeEnum.ROSE]: 'rose',
}

// 其它配置
const otherConfig = {
    // 轮播动画
    isCarousel: false,
}

const option = {
    ...otherConfig,
    type: 'ring',
    tooltip: {
        show: true,
        trigger: 'item',
    },
    legend: {
        show: true,
    },
    dataset: { ...dataJson },
    series: [
        {
            type: 'pie',
            radius: ['40%', '65%'],
            center: ['50%', '60%'],
            roseType: false,
            avoidLabelOverlap: false,
            itemStyle: {
                show: true,
                borderRadius: 10,
                borderColor: '#fff',
                borderWidth: 2,
            },
            label: {
                show: false,
                position: 'center',
                formatter: '{b}',
                fontWeight: 'normal',
                fontSize: 14,
                color: '#454E54',
                textBorderColor: '#ffffff',
                textBorderWidth: 1,
            },
            emphasis: {
                label: {
                    show: true,
                    fontSize: 40,
                    fontWeight: 'bold',
                },
            },
            labelLine: {
                show: false,
            },
        },
    ],
}

export default class Config extends PublicConfigClass implements CreateComponentType {
    public key: string = PieCommonConfig.key

    public chartConfig = cloneDeep(PieCommonConfig)

    // 图表配置项
    public option = echartOptionProfixHandle(option, includes)
}
